<template>
  <div class='book-card'
       @click='detailPage'>
    <div class='thumb'
         @click.stop='preview'>
      <img :src="book.image"
           class='img'
           mode='aspectFit'>
    </div>
    <div class='detail'>
      <div class='row'>
        <div class='right text'>
          {{book.rate}}
          <div class='rate'>
            <Rate :value='book.rate'></Rate>
          </div>
        </div>
        <div class='left text'>
          {{book.title}}
        </div>
      </div>
      <div class='row'>
        <div class='right text'>
          浏览量：{{book.count}}
        </div>
        <div class='left'>
          {{book.author}}
        </div>
      </div>
      <div class='row'>
        <div class='right'>
          {{book.user_info.nickName}}
        </div>
        <div class='left'>
          {{book.publisher}}
        </div>
      </div>
    </div>
  </div>

</template>


<script>
import Rate from '@/components/Rate'
export default {
  props: {
    book: {
      type: Object
    },
    books: {
      type: Array
    }
  },
  computed: {
    detailUrl () {
      return '/pages/me/main'
    }
  },
  methods: {
    detailPage () {
      wx.navigateTo({
        url: '../detail/main?id=' + this.book.id
      })
    },
    preview () {
      wx.previewImage({
        current: this.book.image,
        urls: [this.book.image]
      })
    }
  },
  components: {
    Rate
  }
}
</script>

<style lang='scss' scoped>
.book-card {
  padding: 5px;
  overflow: hidden;
  margin-top: 5px;
  margin-bottom: 5px;
  font-size: 14px;
  .thumb {
    width: 90px;
    height: 90px;
    float: left;
    margin: 0 auto;
    overflow: hidden;
    .img {
      max-width: 100%;
      max-height: 100%;
    }
  }
  .detail {
    margin-left: 100px;
    .row {
      line-height: 20px;
      margin-bottom: 3px;
      margin-right: 8px;
      .right {
        float: right;
        .rate {
          vertical-align: top;
        }
      }
      .left {
        margin-right: 80px;
      }
    }
  }
}
</style>
